package cn.apthink.calendar;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

import cn.apthink.utility.DateUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class DepartmentWorker {
	private String departmentId;
	private LocalDate startDate;
	private LocalDate endDate;
	private int worker;
	
	public DepartmentWorker(String departmentId, String startDate, String endDate, int worker) {
		super();
		this.departmentId = departmentId;
		this.startDate = DateUtil.toDate(startDate);
		this.endDate = DateUtil.toDate(endDate);
		this.worker = worker;
	}

	public boolean contain(LocalDate current) {
		return !startDate.isAfter(current) && !endDate.isBefore(current);
	}

	public static DepartmentWorker testData() {
		DepartmentWorker departmentWorker = new DepartmentWorker();
		departmentWorker.setStartDate(LocalDate.parse("2025-02-09"));
		departmentWorker.setEndDate(LocalDate.parse("2025-02-17"));
		departmentWorker.setDepartmentId("factory");
		departmentWorker.setWorker(1);
		return departmentWorker;
	}
	
	public static List<DepartmentWorker> testDatas() {
		List<DepartmentWorker> departmentWorkers = new ArrayList<DepartmentWorker>();
		DepartmentWorker departmentWorker = DepartmentWorker.testData();
		departmentWorkers.add(departmentWorker);
		
		departmentWorker = new DepartmentWorker();
		departmentWorker.setStartDate(LocalDate.parse("2025-01-03"));
		departmentWorker.setEndDate(LocalDate.parse("2025-01-03"));
		departmentWorker.setWorker(2);
		departmentWorker.setDepartmentId("floor");
		departmentWorkers.add(departmentWorker);
		
		departmentWorker = new DepartmentWorker();
		departmentWorker.setStartDate(LocalDate.parse("2025-01-03"));
		departmentWorker.setEndDate(LocalDate.parse("2025-01-03"));
		departmentWorker.setWorker(1);
		departmentWorker.setDepartmentId("l1");
		departmentWorkers.add(departmentWorker);

		departmentWorker = new DepartmentWorker();
		departmentWorker.setStartDate(LocalDate.parse("2025-01-03"));
		departmentWorker.setEndDate(LocalDate.parse("2025-01-03"));
		departmentWorker.setWorker(2);
		departmentWorker.setDepartmentId("l2");
		departmentWorkers.add(departmentWorker);
		return departmentWorkers;
	}

}
